﻿@*@model zichan.Entity.CompanyClass*@
@model zichan.Models.AssetListModel
@{
    ViewBag.Title = "添加资产分类";
}

@section Pagetitle{
    @AdminCommon.PageTitle("资产分类管理", "添加")
}

<div class="form-group col-md-offset-3 col-md-9">
    <input type="radio" id="selectOne" name="createType" value="one" />添加单个
    <input type="radio" id="selectList" name="createType" value="list" checked />批量添加
</div>
@using (Html.BeginForm("CreateList", "AsseteClass", FormMethod.Post, new { @class = "form-horizontal",@name="form" }))
{
    <div class="form-body">
        @Html.AntiForgeryToken()
        <div class="form-group ">
            <label class="col-md-3 control-label xh">资产名称:</label>
            <div class="col-md-9">
                @Html.TextAreaFor(o => o.nameList, new { @class = "form-control input-large", @placeholder = "格式：资产名称，资产标识；每行一条数据"})
                <span class="help-block">
                    @Html.ValidationMessageFor(o => o.nameList)
                </span>
            </div>
        </div>
        <div class="form-actions">
            <div class="row">
                <div class="col-md-offset-3 col-md-9">
                    <button type="submit" class="btn green">提交</button>
                    <a href="/AsseteClass/Index" class="btn default">返回</a>
                </div>
            </div>
        </div>
    </div>
}

@section footer{
    @*@Scripts.Render("~/bundles/jqueryval")*@
    <script type="text/javascript">
    $(function(){
        $("#selectOne").on("click", function () {
            window.location.href = "/AsseteClass/Create";
        });
        $("form").submit(function () {
            var list = $("#nameList").val().split(/\r?\n/);
            var bool = 0;
            $.each(list, function () {
                //var list1 = this.split(",");
                if (this.match(/[\w*|\S][\,|，][.*|\S|\s.+]/) == null) {
                    bool = 1;
                }
            });
            if (bool == 1) {
                $(".field-validation-valid").html("<span style='color:red;'>请输入正确格式的数据</span>");
                return false
            }
            else {
                $(".field-validation-valid").html("");
                return true;
            }
        });
    });
    </script>
}

